package com.syt.service.service;

import com.syt.service.dao.PhoneBaseMapper;
import com.syt.service.pojo.PhoneBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 基础数据 服务类
 * @author syt
 */
@Service
public class PhoneBaseService {

    @Autowired(required = false)
    private PhoneBaseMapper phoneBaseMapper;

    /**
     * 根据id查询数据
     * @param id
     * @return
     */
    public PhoneBase getPhoneByid(Integer id) {
        PhoneBase phoneBase = phoneBaseMapper.selectByPrimaryKey(id);
        return phoneBase;
    }

    /**
     * 获取全部phonebase 基础数据
     * @return
     */
    public List<PhoneBase> allListPhone() {
        return phoneBaseMapper.allListPhone();
    }

    /**
     * 增加基础数据
     * @param phoneBase
     * @return
     */
    public Integer addPhonoBase(PhoneBase phoneBase) {
        return phoneBaseMapper.insertSelective(phoneBase);
    }

    /**
     * 更新数据
     * @param phoneBase
     * @return
     */
    public Integer updatePhoneBase(PhoneBase phoneBase) {
        return phoneBaseMapper.updateByPrimaryKeySelective(phoneBase);
    }

    /**
     * 根据id删除 基础数据 base
     * @param phoneId
     * @return
     */
    public Integer deletePhoneBaseByid(Integer phoneId) {
        return phoneBaseMapper.deleteByPrimaryKey(phoneId);
    }

    /**
     *  根据 name 删除基础数据
     * @param phoneName
     * @return
     */
    public Integer deleteByName(String phoneName) {
        return phoneBaseMapper.deleteByName(phoneName);
    }

    /**
     * 查询得出分类数据
     * @param name
     * @return
     */
    public List<PhoneBase> classifyPhone(String name) {
        return phoneBaseMapper.classifyPhone(name);
    }
}
